<?php
namespace app\index\controller;

class Index extends Base
{
    public function index(){
    	//获取首页大图数据

    	$mainFeatureds = model('Featured')->getFeaturedsByType(0);
        //获取首页右侧广告位数据
    	$rightFeatureds = model('Featured')->getFeaturedsByType(1);
    	//获取一级分类数据
    	$featuredCategorys = model('Category')->getCategorysByParentId(0,1,0,5);
    	//获取二级分类数据
    	$seFeaturedCategorys = [];
    	//获取推位团购商品数据
    	$featuredDeals = [];
    	foreach ($featuredCategorys as $k => $v) {
    		$featuredDeals[] = model('Deal')->getDeals(['status' => 1,'category_id' => $v->id],5);
    		$seFeaturedCategorys[] = model('Category')->getCategorysByParentId($v->id,1,0,4);
    	}
        return $this->fetch('',[
        	'mainFeatureds' => $mainFeatureds,
        	'rightFeatureds' => $rightFeatureds,
        	'featuredDeals' => $featuredDeals,
        	'featuredCategorys' => $featuredCategorys,
        	'seFeaturedCategorys' => $seFeaturedCategorys,
        ]);
    }
}
